package decorate;

/**
 * 装饰器模式测试
 * 
 * @author Yu Yufeng
 *
 */
public class Test {
	public static void main(String[] args) {
		Component c1 = new ConcreteComponent(); // 首先创建需要被装饰的原始对象(即要被装饰的对象)
		Decorator decoratorA = new ConcreteDecoratorA(c1); // 给对象透明的增加功能A并调用
		decoratorA.operation();

		Decorator decoratorB = new ConcreteDecoratorB(c1); // 给对象透明的增加功能B并调用
		decoratorB.operation();

		System.out.println("------------------------------------");

		// 装饰器也可以装饰具体的装饰对象，此时相当于给对象在增加A的功能基础上再添加功能B
		Decorator decoratorBandA = new ConcreteDecoratorB(decoratorA);
		decoratorBandA.operation();
	}
}